﻿using System;
using System.Collections.Generic;
using System.Xml;

namespace SDT.CrawlSystem.Servers.Filters
{
    /// <summary>
    /// Written by TungNX
    /// </summary>
    public sealed class Tag
    {
        public string Name = null;
        public string Id = null;
        public string AttName = null;
        public string AttValue = null;
        public IList<string> StartWithList = new List<string>();

        public Tag(XmlNode n)
        {
            if (n == null)
                throw new ArgumentNullException();

            Name = n.Attributes["Name"].Value;            
            if (n.Attributes["Id"] != null && n.Attributes["Id"].Value.Length > 0)
                Id = n.Attributes["Id"].Value;

            AttName = n.Attributes["AttName"].Value;
            AttValue = n.Attributes["AttValue"].Value;

            var l = n.SelectNodes("StartWith");
            if(l != null)
                foreach (var i in l)
                    StartWithList.Add((i as XmlNode).InnerText);
        }
    }
}